import {
    PicLeftOutlined,
    TableOutlined,
    DropboxOutlined,
    AreaChartOutlined,
    BarChartOutlined,
    PieChartOutlined,
    DotChartOutlined,
    RadarChartOutlined,
    AliwangwangOutlined,
    SlackSquareOutlined,
    SecurityScanOutlined,
    YahooOutlined,
    SketchOutlined,
    TeamOutlined,
    QrcodeOutlined,
    RocketOutlined,
    UsergroupAddOutlined


} from "@ant-design/icons"
let menulist = [
    {
        title: "就业升学信息",
        icon: <PicLeftOutlined />,
        children: [
            {
                id: 11,
                title: "就业升学表格",
                path: "/home/workform",
                icon: <TableOutlined />,
            }
        ]
    },
    {

        title: "就业升学可视化",
        icon: <DropboxOutlined />,
        children: [
            {
                id: 21,
                title: "就业升学一览",
                path: "/home/workyears",
                icon: <AreaChartOutlined />
            },
            {
                id: 22,
                title: "学历结构",
                path: "/home/employment",
                icon: <AreaChartOutlined />
            },
            {
                id: 23,
                title: "性别占比",
                path: "/home/sexstract",
                icon: <BarChartOutlined />
            },
            {
                id: 24,
                title: "就业分布",
                path: "/home/map",
                icon: <PieChartOutlined />
            },
            {
                id: 25,
                title: "学院详情",
                path: "/home/college",
                icon: <DotChartOutlined />
            },
            {
                id: 26,
                title: "专业详情",
                path: "/home/major",
                icon: <RadarChartOutlined />
            }
        ],

    },
    {
        title: "论坛中心",
        icon: <AliwangwangOutlined />,
        children: [
            {
                id: 31,
                title: "学生论坛",
                path: "/home/forum",
                icon: <SlackSquareOutlined />
            },
            {
                id: 32,
                title: "聊天室",
                path: "/home/chat",
                icon: <SlackSquareOutlined />
            }
        ]
    },
    {
        title: "权限管理模块",
        icon: <SecurityScanOutlined />,
        children: [
            {
                id: 41,
                title: "分类权限管理",
                path: "/home/type",
                icon: <YahooOutlined />
            },
            {
                id: 42,
                title: "用户权限管理",
                path: "/home/juruser",
                icon: <SketchOutlined />
            }
        ]
    },
    {
        title: "管理模块",
        icon: <TeamOutlined />,
        children: [
            {
                id: 51,
                title: "账号信息管理",
                path: "/home/account",
                icon: <QrcodeOutlined />
            },
            {
                id: 52,
                title: "就业信息上传",
                path: "/home/authentication",
                icon: <RocketOutlined />
            },
            {
                id: 53,
                title: "教师资格认证",
                path: "/home/upload",
                icon: <UsergroupAddOutlined />
            }

        ]
    }

]

let newMenu = [
    {
        title: "就业升学信息",
        icon: <PicLeftOutlined />,
        children: [
        ]
    },
    {

        title: "就业升学可视化",
        icon: <DropboxOutlined />,
        children: [
        ],

    },
    {
        title: "论坛中心",
        icon: <AliwangwangOutlined />,
        children: [
        ]
    },
    {
        title: "权限管理模块",
        icon: <SecurityScanOutlined />,
        children: [
        ]
    },
    {
        title: "管理模块",
        icon: <TeamOutlined />,
        children: [
        ]
    }

]

const handleMenu = (arr) => {
    // 筛选第二层
    for (let i = 0; i < menulist.length; i++) {
        for (let j = 0; j < menulist[i].children.length; j++) {
            for (let k = 0; k < arr.length; k++) {
                if (arr[k] === menulist[i].children[j].id) {
                    // 先判断是否已经存在
                    let index=newMenu[i].children.findIndex(item=>{
                        return item.id===menulist[i].children[j].id
                    })
                    
                    if(index<=0){
                        // console.log(index);
                        newMenu[i].children.push(menulist[i].children[j])
                        break
                    }
                    
                }
            }
        }
    }

    // 删除第二层是空的
    newMenu = newMenu.filter(item => item.children.length > 0)

    // console.log(newMenu, menulist)
    // console.log(Object.prototype.toString.call(newMenu))
    // console.log(Object.prototype.toString.call(menulist))
    return newMenu
}

export {
    handleMenu,
    menulist
}